<template>
  <div class="container">
    <normal-title title='我的'></normal-title>
    <div class="user-info">
      <div class="avatar">
        <open-data type="userAvatarUrl"></open-data>
      </div>
      <open-data
        class="user-name"
        type="userNickName"
      ></open-data>
    </div>
    <img
      class="slice-img"
      src="../../images/personal_bg.png"
      mode="widthFix"
    >
    <div class="session-1">
      <a
        hover-class="none"
        class="row"
        href="/pages/order/main"
      ><img
          class="icon"
          src="../../images/personal_icon_3.png"
          mode="aspectFit"
        >
        <div class="btn-text">
          <p>我的订单</p>
        </div>
        <img
          class="icon-right"
          src="../../images/arrow_right.png"
          mode="aspectFit"
        >
      </a>
      <a
        hover-class="none"
        class="row"
        href="/pages/collect/main"
      >
        <img
          class="icon"
          src="../../images/personal_icon_2.png"
          mode="aspectFit"
        >
        <div class="btn-text">
          <p>收藏夹</p>
        </div>
        <img
          class="icon-right"
          src="../../images/arrow_right.png"
          mode="aspectFit"
        >
      </a>
      <a
        hover-class="none"
        href="/pages/sales/main"
        class="row"
        v-if="isSaler"
      >
        <img
          class="icon"
          src="../../images/personal_icon_1.png"
          mode="aspectFit"
        >
        <div class="btn-text">
          <p>分销中心</p>
        </div>
        <img
          class="icon-right"
          src="../../images/arrow_right.png"
          mode="aspectFit"
        >
      </a>
    </div>
    <div class="session-2">
      <div class="col between icon-group">
        <a>
          <img
            class="image"
            @click="userAddress"
            src="../../images/address.png"
            mode="aspectFit"
          ></a>
        <div class="icon-group-name">收货地址</div>
      </div>
      <div class="col between icon-group">
        <a
          hover-class="none"
          href="/pages/contact/main"
        >
          <img
            class="image"
            src="../../images/contact_us.png"
            mode="aspectFit"
          ></a>
        <div class="icon-group-name">联系我们</div>
      </div>
      <div class="col between icon-group">
        <a
          hover-class="none"
          href="/pages/aboutUs/main"
        >
          <img
            class="image"
            src="../../images/about_us.png"
            mode="aspectFit"
          >
        </a>
        <div class="icon-group-name">关于我们</div>
      </div>
    </div>
  </div>
</template>

<script>
import NormalTitle from "@/components/NormalTitle";
import { judgeUser } from "@/utils";
export default {
  components: {
    NormalTitle
  },
  data() {
    return {
      userInfo: {},
      isSaler: false
    };
  },
  methods: {
    userAddress() {
      wx.chooseAddress({
        fail() {
          wx.getSetting({
            success(res) {
              if (!res.authSetting["scope.address"]) {
                wx.openSetting();
              }
            }
          });
        }
      });
    },
    async userType() {
      var res = await judgeUser();
      if (res.data.data&&res.data.data.status === 2) {
        this.isSaler = true;
      }else{
        this.isSaler = false
      }
    }
  },
  onShow() {
    this.userType();
  }
};
</script>

<style>
page {
  height: 100%;
  background: #f0f0f0;
}
</style>

<style scoped lang="scss">
.container {
  text-align: center;
  .user-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 250rpx;
    background: #fff;
    .avatar {
      overflow: hidden;
      width: 65px;
      height: 65px;
      border-radius: 50%;
      margin-bottom: 25rpx;
    }
  }
  .slice-img {
    width: 750rpx;
  }
  .session-1 {
    font-size: 32rpx;
    margin: 0 auto;
    padding: 25rpx 25rpx;
    width: 700rpx;
    // height: 400rpx;
    background: #fff;
    border-radius: 20rpx;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    
    .row {
      display: flex;
      align-items: center;
      width: 600rpx;
      justify-content: space-between;
      height: 100rpx;
       border-top: 1rpx solid #F1F1F1;
      .icon {
        width: 46rpx;
        height: 46rpx;
        font-size: 0;
      }
      .btn-text {
        width: 100%;
        text-align: left;
        margin-left: 20rpx;
        margin-bottom: 0rpx;
        font-weight: 400;
      }
      .icon-right {
        width: 40rpx;
        height: 40rpx;
        font-size: 0;
      }
    }
    .row:nth-child(1){
      border:none;
    }
  }
  .session-2 {
    margin: 30rpx auto 0;
    width: 700rpx;
    height: 200rpx;
    background: #fff;
    border-radius: 20rpx;
    display: flex;
    justify-content: space-around;
    align-items: center;
    .icon-group {
      // height: 150rpx;
      .image {
        width: 100rpx;
        height: 100rpx;
      }
      .icon-group-name {
        font-size: 24rpx;
      }
    }
  }
}
</style>
